package com.example.ResponsibleChainPattern_LinkedList;

/**
 * <pre>
 * 功能描述：
 * https://mp.weixin.qq.com/s/W5ZVGHwLAK282KUOLJLOkQ
 * </pre>
 *
 * @author: 李明杰
 * @date: 2022/10/27 22:12
 */
public abstract class AbstractHandler {
    private AbstractHandler nextHandler;

    /**
     * 具体参数拦截逻辑,给子类去实现
     */
    public void filter(String request, String response) {
        doFilter(request, response);
        if (getNextHandler() != null) {
            getNextHandler().filter(request, response);
        }
    }

    public AbstractHandler getNextHandler() {
        return nextHandler;
    }

    public void setNextHandler(AbstractHandler nextHandler) {
        this.nextHandler = nextHandler;
    }

    public abstract void doFilter(String request, String response);
}
